package com.yunxi.controller.otd;

import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import com.yunxi.otd.pojo.OtdProjectCarOrderQueryVO;
import com.yunxi.otd.pojo.OtdProjectCarOrderSaveVO;
import com.yunxi.otd.service.OtdProjectCarOrderDubboService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 项目用车单 前端控制器
 * </p>
 *
 * @author XUQI
 * @since 2019-06-12
 */
@RestController
@RequestMapping("/admin/project")
@Api(tags = "OTD:PROJECTCAR", description = "项目用车单接口")
public class OtdProjectCarOrderController {

    private static final Logger logger = LoggerFactory.getLogger(OtdProjectCarOrderController.class);

    @Autowired
    OtdProjectCarOrderDubboService otdProjectCarOrderDubboService;

    @GetMapping("/page")
    @ApiOperation(value = "查询分页")
    public ApiResult page(OtdProjectCarOrderQueryVO queryVO, Integer pageNum, Integer pageSize) {
        return ResponseUtil.ok(otdProjectCarOrderDubboService.findPageByVO(queryVO, pageNum, pageSize));
    }

    @GetMapping("/load")
    @ApiOperation(value = "读取单个")
    public ApiResult load(String id) {
        return ResponseUtil.ok(otdProjectCarOrderDubboService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "保存信息")
    public ApiResult save(@RequestBody OtdProjectCarOrderSaveVO addVO, @CurrentUser LoginInfo loginInfo) {
        return otdProjectCarOrderDubboService.saveOrUpdate(addVO, loginInfo);
    }

    @PostMapping("/confirm")
    @ApiOperation(value = "确认")
    public ApiResult confirm(@RequestBody OtdProjectCarOrderSaveVO saveVO, @CurrentUser LoginInfo loginInfo) {
        return otdProjectCarOrderDubboService.confirm(saveVO, loginInfo);
    }

    @PostMapping("/import")
    @ApiOperation(value = "导入")
    public ApiResult importData(@RequestBody List<Map<String, Object>> dataList, @CurrentUser LoginInfo loginInfo) {
        return otdProjectCarOrderDubboService.importData(dataList);
    }

    @PostMapping("/remover")
    @ApiOperation(value = "删除")
    public ApiResult remover(@RequestBody List<String> ids) {
        return otdProjectCarOrderDubboService.remover(ids);
    }

    @GetMapping("/export")
    @ApiOperation(value = "导出")
    public ApiResult export(OtdProjectCarOrderQueryVO queryVO) {
        return ResponseUtil.ok(otdProjectCarOrderDubboService.findListByVO(queryVO));
    }


/*@PostMapping("/export")
@ApiOperation(value = "导出excel")
public Object export(@RequestParam Map<String,Object> params) throws Exception {
return ResponseUtil.ok(otdProjectCarOrderDubboService.findMapByList(params));
}*/
}
